import tensorflow
import numpy as np


class Dense(object):

    def __init__(self, x, input_size, output_size, act_fun=None, tf=tensorflow, d_type=np.float32):
        self.tf = tf
        self.x = x
        self.Weights = self.tf.Variable(self.tf.truncated_normal([input_size, output_size], stddev=0.1, dtype=d_type),
                                        dtype=d_type)
        self.Biases = self.tf.Variable(self.tf.zeros([output_size], dtype=d_type), dtype=d_type)
        self.x_multiply_Weights = self.tf.matmul(self.x, self.Weights)
        self.x_multiply_Weights_plus_Biases = self.x_multiply_Weights + self.Biases
        self.activate_function = act_fun
        if self.activate_function is None:
            self.y = self.x_multiply_Weights_plus_Biases
        else:
            self.y = self.activate_function(self.x_multiply_Weights_plus_Biases)
